ROOT=../..
EXTRALIBS=-pthread
include $(ROOT)/Make.defines.linux

# C_SRCS = $(wildcard  ./*.c)	#找到所有的.c文件
C_SRCS = cli_socket_handle.c format.c serv_socket_handle.c server_detect.c
CPP_SRCS = $(wildcard ./*.cpp)	#找到所有的.cpp文件

C_OBJS   = $(C_SRCS:%.c=%.o)
CPP_OBJS = $(CPP_SRCS:%.cpp=%.o)

LIB = libnet.a
LIB_SO = libnet.so
all : $(LIB_SO)

test:test.c $(LIB_SO)
	$(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS) $(LDLIBS) -lnet -lutility -llog

$(LIB_SO) : $(C_OBJS) $(CPP_OBJS)
	$(CC) -shared -fPIC -o $@ $(C_OBJS) $(CPP_OBJS) $(LDLIBS) -llog -lencrypt -lkernelList -luserSqliteOp -L$(ROOT)/$(EVENET_LIB_PATH) -levent
	cp $@ $(ROOT)/lib
	
serv_socket_handle.o:serv_socket_handle.c
	$(CC) $(CFLAGS) -g -Werror -c $^ -o $@ -fPIC
cli_socket_handle.o:cli_socket_handle.c
	$(CC) $(CFLAGS) -g -Werror -c $^ -o $@ -fPIC

%.o:%.c
	$(CC)  $(CFLAGS) -c $^ -o $@ -fPIC
%.o:%.cpp
	$(CPLUSPLUS)  $(CFLAGS) -c $^ -o $@ -fPIC

clean:
	rm -f $(TEMPFILES) *.o $(C_OBJS) $(CPP_OBJS) $(LIB) $(LIB_SO) $(ROOT)/lib/$(LIB) $(ROOT)/lib/$(LIB_SO) *.log test
